package com.wn.ziroombackend.controller;


import com.github.pagehelper.PageInfo;
import com.wn.ziroombackend.entity.Owner;
import com.wn.ziroombackend.service.OwnerService;
import com.wn.ziroombackend.service.RoomService;
import com.wn.ziroombackend.utils.R;
import com.wn.ziroombackend.utils.RoomCondition;
import com.wn.ziroombackend.vo.OwnerVo;
import com.wn.ziroombackend.vo.RoomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-27 10:56:29
 */
@RestController
@RequestMapping("/owner")
public class OwnerController {

    @Autowired
    private OwnerService ownerService;
    @Autowired
    private RoomService roomService;

    @GetMapping("/getAll")
    public R getAll(){
        List<Owner> list = ownerService.list();
        return R.ok("ok").data("ownerList", list);

    }

    @PostMapping("/list")
    public R list(
            @RequestParam(defaultValue = "1") Integer num,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestBody RoomCondition roomCondition
    ) {

        PageInfo<OwnerVo> ownerList = ownerService.getOwnerList(num, size, roomCondition.getQuartersName(), roomCondition.getOwnerName());

        return R.ok("ok").data("ownerList", ownerList);

    }



}

